﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Approve.aspx.cs" Inherits="WebPresentation.Approve" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<script type="text/javascript" src="Scripts/jquery.ui.datepicker.js"></script>
    <script type="text/javascript" src="Scripts/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="Scripts/jquery-ui-1.8.20.custom.min.js"></script>
    <script src="Scripts/jquery.validate.min.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(function () {

            $('.hiddenField, #MainContent_dtgApprove th:nth-child(6)').hide();
            $('#MainContent_dtgApprove tr').each(function () {
                if (!$(this).find("td").eq(4).find("span input").is(":checked")) {
                    $(this).find("td").eq(6).text("Not set");
                }
                var storePath = $(this).find("td.storePath").text();
                $(this).find("td.storePath").html("<a href=" + storePath + ">Download</a>");
            });

        });
	      
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:GridView ID="dtgApprove" runat="server" AllowPaging="True" 
                AutoGenerateColumns="False" DataKeyNames="docID" 
                DataSourceID="ObjectDataSource3" style="margin-right: 0px" 
        Width="891px" ondatabound="dtgApprove_DataBound" 
        onrowediting="dtgApprove_RowEditing" 
        onselectedindexchanged="dtgApprove_SelectedIndexChanged">
        <Columns>
            <asp:CommandField ShowEditButton="True" SelectText="View recipients" />
            <asp:CommandField SelectText="View recipients" ShowSelectButton="True" 
                Visible="False" />
            <asp:CheckBoxField DataField="status" HeaderText="status" 
                        SortExpression="status" />
            <asp:BoundField DataField="DocCode" HeaderText="DocCode" ReadOnly="True" 
                        SortExpression="DocCode" />
            <asp:CheckBoxField DataField="inOut" HeaderText="inOut" 
                        SortExpression="inOut" ReadOnly="True" Visible="False" />
            <asp:BoundField DataField="shortenedDetail" HeaderText="shortenedDetail" 
                        SortExpression="shortenedDetail" ReadOnly="True" />
            <asp:BoundField DataField="storePath" HeaderText="storePath" 
                        SortExpression="storePath" ReadOnly="True" >
            <ItemStyle CssClass="storePath" />
            </asp:BoundField>
            <asp:BoundField DataField="docID" HeaderText="docID" InsertVisible="False" 
                        ReadOnly="True" SortExpression="docID" >
            <ItemStyle CssClass="hiddenField" />
            </asp:BoundField>
            <asp:BoundField DataField="Sender" HeaderText="Sender" 
                        SortExpression="Sender" ReadOnly="True" />
            <asp:BoundField DataField="dateOfReceipt" HeaderText="dateOfReceipt" 
                        SortExpression="dateOfReceipt" ReadOnly="True" />
        </Columns>
    </asp:GridView>
            <asp:ObjectDataSource ID="ObjectDataSource3" runat="server" 
                DeleteMethod="Delete" InsertMethod="AddNewDocument" 
                SelectMethod="GetAllPendingDocuments" TypeName="BusinessLogic.DocumentBO" 
                UpdateMethod="ApproveDoc">
                <DeleteParameters>
                    <asp:Parameter Name="docID" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="docNumber" Type="Int32" />
                    <asp:Parameter Name="dtID" Type="Int32" />
                    <asp:Parameter Name="docSender" Type="Int32" />
                    <asp:Parameter Name="dateOfReceipt" Type="DateTime" />
                    <asp:Parameter Name="adoptedBy" Type="Int32" />
                    <asp:Parameter Name="inOut" Type="Boolean" />
                    <asp:Parameter Name="shortenedDetail" Type="String" />
                    <asp:Parameter Name="storePath" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="status" Type="Boolean" />
                    <asp:Parameter Name="docID" Type="Int32" />
                </UpdateParameters>
            </asp:ObjectDataSource>
        <asp:Label ID="lblDocID" runat="server" Text="Label" Visible="False"></asp:Label>
    <div align="center">
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AutoGenerateColumns="False" DataSourceID="RecipientsObjectSource">
            <Columns>
                <asp:BoundField DataField="Recipient" 
                    HeaderText="List of recipients for this doc" SortExpression="Recipient" />
            </Columns>
        </asp:GridView>
        <asp:ObjectDataSource ID="RecipientsObjectSource" runat="server" 
            DeleteMethod="DeleteRecipient" InsertMethod="AddNewRecipient" 
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllRecipients" 
            TypeName="BusinessLogic.RecipientBO" UpdateMethod="UpdateRecipients">
            <DeleteParameters>
                <asp:Parameter Name="docID" Type="Int32" />
                <asp:Parameter Name="depID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="docID" Type="Int32" />
                <asp:Parameter Name="depID" Type="Int32" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="lblDocID" DefaultValue="1" Name="docID" 
                    PropertyName="Text" Type="String" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="depID" Type="Int32" />
                <asp:Parameter Name="docID" Type="Int32" />
                <asp:Parameter Name="original_depID" Type="Int32" />
            </UpdateParameters>
        </asp:ObjectDataSource>
    </div>
        </asp:Content>
